﻿// Decompiled with JetBrains decompiler
// Type: Bannerlord.BUTR.Shared.Utils.MBSubModuleBaseSimpleWrapper
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using HarmonyLib.BUTR.Extensions;
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;

#nullable enable
namespace Bannerlord.BUTR.Shared.Utils
{
  public class MBSubModuleBaseSimpleWrapper : MBSubModuleBase
  {
    private MBSubModuleBaseSimpleWrapper.OnSubModuleLoadDelegate? OnSubModuleLoadInstance { get; }

    private MBSubModuleBaseSimpleWrapper.OnSubModuleUnloadedDelegate? OnSubModuleUnloadedInstance { get; }

    private MBSubModuleBaseSimpleWrapper.OnBeforeInitialModuleScreenSetAsRootDelegate? OnBeforeInitialModuleScreenSetAsRootInstance { get; }

    private MBSubModuleBaseSimpleWrapper.OnGameStartDelegate? OnGameStartInstance { get; }

    private MBSubModuleBaseSimpleWrapper.OnApplicationTickDelegate? OnApplicationTickInstance { get; }

    private MBSubModuleBaseSimpleWrapper.InitializeGameStarterDelegate? InitializeGameStarterInstance { get; }

    private MBSubModuleBaseSimpleWrapper.AfterRegisterSubModuleObjectsDelegate? AfterRegisterSubModuleObjectsInstance { get; }

    private MBSubModuleBaseSimpleWrapper.AfterAsyncTickTickDelegate? AfterAsyncTickTickInstance { get; }

    public MBSubModuleBase SubModule { get; }

    public MBSubModuleBaseSimpleWrapper(MBSubModuleBase subModule)
    {
      this.SubModule = subModule;
      this.OnSubModuleLoadInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.OnSubModuleLoadDelegate, MBSubModuleBase>(subModule, "OnSubModuleLoad");
      this.OnSubModuleUnloadedInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.OnSubModuleUnloadedDelegate, MBSubModuleBase>(subModule, "OnSubModuleUnloaded");
      this.OnBeforeInitialModuleScreenSetAsRootInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.OnBeforeInitialModuleScreenSetAsRootDelegate, MBSubModuleBase>(subModule, "OnBeforeInitialModuleScreenSetAsRoot");
      this.OnGameStartInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.OnGameStartDelegate, MBSubModuleBase>(subModule, "OnGameStart");
      this.OnApplicationTickInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.OnApplicationTickDelegate, MBSubModuleBase>(subModule, "OnApplicationTick");
      this.InitializeGameStarterInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.InitializeGameStarterDelegate, MBSubModuleBase>(subModule, "InitializeGameStarter");
      this.AfterRegisterSubModuleObjectsInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.AfterRegisterSubModuleObjectsDelegate, MBSubModuleBase>(subModule, "AfterRegisterSubModuleObjects");
      this.AfterAsyncTickTickInstance = AccessTools2.GetDelegate<MBSubModuleBaseSimpleWrapper.AfterAsyncTickTickDelegate, MBSubModuleBase>(subModule, "AfterAsyncTickTick");
    }

    protected override void OnSubModuleLoad()
    {
      MBSubModuleBaseSimpleWrapper.OnSubModuleLoadDelegate moduleLoadInstance = this.OnSubModuleLoadInstance;
      if (moduleLoadInstance == null)
        return;
      moduleLoadInstance();
    }

    protected override void OnSubModuleUnloaded()
    {
      MBSubModuleBaseSimpleWrapper.OnSubModuleUnloadedDelegate unloadedInstance = this.OnSubModuleUnloadedInstance;
      if (unloadedInstance == null)
        return;
      unloadedInstance();
    }

    protected override void OnApplicationTick(float dt)
    {
      MBSubModuleBaseSimpleWrapper.OnApplicationTickDelegate applicationTickInstance = this.OnApplicationTickInstance;
      if (applicationTickInstance == null)
        return;
      applicationTickInstance(dt);
    }

    protected override void OnBeforeInitialModuleScreenSetAsRoot()
    {
      MBSubModuleBaseSimpleWrapper.OnBeforeInitialModuleScreenSetAsRootDelegate setAsRootInstance = this.OnBeforeInitialModuleScreenSetAsRootInstance;
      if (setAsRootInstance == null)
        return;
      setAsRootInstance();
    }

    protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
    {
      MBSubModuleBaseSimpleWrapper.OnGameStartDelegate gameStartInstance = this.OnGameStartInstance;
      if (gameStartInstance == null)
        return;
      gameStartInstance(game, gameStarterObject);
    }

    protected override void InitializeGameStarter(Game game, IGameStarter starterObject)
    {
      MBSubModuleBaseSimpleWrapper.InitializeGameStarterDelegate gameStarterInstance = this.InitializeGameStarterInstance;
      if (gameStarterInstance == null)
        return;
      gameStarterInstance(game, starterObject);
    }

    protected override void AfterAsyncTickTick(float dt)
    {
      MBSubModuleBaseSimpleWrapper.AfterAsyncTickTickDelegate tickTickInstance = this.AfterAsyncTickTickInstance;
      if (tickTickInstance == null)
        return;
      tickTickInstance(dt);
    }

    public override bool DoLoading(Game game) => this.SubModule.DoLoading(game);

    public override void OnGameLoaded(Game game, object initializerObject)
    {
      this.SubModule.OnGameLoaded(game, initializerObject);
    }

    public override void OnCampaignStart(Game game, object starterObject)
    {
      this.SubModule.OnCampaignStart(game, starterObject);
    }

    public override void BeginGameStart(Game game) => this.SubModule.BeginGameStart(game);

    public override void OnGameEnd(Game game) => this.SubModule.OnGameEnd(game);

    public override void OnGameInitializationFinished(Game game)
    {
      this.SubModule.OnGameInitializationFinished(game);
    }

    public override void OnBeforeMissionBehaviorInitialize(Mission mission)
    {
      this.SubModule.OnBeforeMissionBehaviorInitialize(mission);
    }

    public override void OnMissionBehaviorInitialize(Mission mission)
    {
      this.SubModule.OnMissionBehaviorInitialize(mission);
    }

    public override void OnMultiplayerGameStart(Game game, object starterObject)
    {
      this.SubModule.OnMultiplayerGameStart(game, starterObject);
    }

    public override void OnNewGameCreated(Game game, object initializerObject)
    {
      this.SubModule.OnNewGameCreated(game, initializerObject);
    }

    public override void RegisterSubModuleObjects(bool isSavedCampaign)
    {
      this.SubModule.RegisterSubModuleObjects(isSavedCampaign);
    }

    public override void OnAfterGameInitializationFinished(Game game, object starterObject)
    {
      this.SubModule.OnAfterGameInitializationFinished(game, starterObject);
    }

    public override void AfterRegisterSubModuleObjects(bool isSavedCampaign)
    {
      MBSubModuleBaseSimpleWrapper.AfterRegisterSubModuleObjectsDelegate moduleObjectsInstance = this.AfterRegisterSubModuleObjectsInstance;
      if (moduleObjectsInstance == null)
        return;
      moduleObjectsInstance(isSavedCampaign);
    }

    public override void OnConfigChanged() => this.SubModule.OnConfigChanged();

    public override void OnInitialState() => this.SubModule.OnInitialState();

    private delegate void OnSubModuleLoadDelegate();

    private delegate void OnSubModuleUnloadedDelegate();

    private delegate void OnBeforeInitialModuleScreenSetAsRootDelegate();

    private delegate void OnGameStartDelegate(Game game, IGameStarter gameStarterObject);

    private delegate void OnApplicationTickDelegate(float dt);

    private delegate void InitializeGameStarterDelegate(Game game, IGameStarter starterObject);

    private delegate void AfterRegisterSubModuleObjectsDelegate(bool isSavedCampaign);

    private delegate void AfterAsyncTickTickDelegate(float dt);
  }
}
